{extend name="common/form" /}
    {block name="form" /}
        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
        <div class="widget am-cf">
            <div class="widget-head am-cf">
                <div class="widget-title am-fl">菜单添加</div>
                <div class="widget-function am-fr">
                    <a href="javascript:;" class="am-icon-cog"></a>
                </div>
            </div>
            <div class="widget-body am-fr">

                <form class="am-form tpl-form-border-form tpl-form-border-br">
                    <div class="am-form-group">
                        {present name="$infos.id"}
                        <input type="hidden" value="{$infos.id}" name="id">
                        {/present}
                        <label for="user-phone"  class="am-u-sm-3 am-form-label">上级菜单
                        </label>
                        <div class="am-u-sm-9">



                            <select name="parent_id" required="required" data-am-selected="{searchBox: 2}">
                                <option value="0">最高级</option>
                                {php}
                                    function menulist($data,$line ='',$info=[]){
                                        if($data[0]['level']>1)
                                            $line.='---';
                                            foreach($data as $v){
                                            {/php}
                                                <option  value="{$v.id}" {php} if(isset($info['parent_id'])){ if($info['parent_id'] ==$v['id'])echo 'selected';}{/php}>{$line}{$v.name}</option>
                                            {php}
                                            if($v['son']){
                                                menulist($v['son'],$line,$info);
                                            }
                                        }
                                    }
                                if(!isset($infos)){
                                 $infos = [];
                                }

                                    menulist($menuList,'',$infos);
                                {/php}
                            </select>

                        </div>
                    </div>
                    <div class="am-form-group">
                        <label class="am-u-sm-3 am-form-label">
                            菜单名
                        </label>
                        <div class="am-u-sm-9">
                            <input type="text" name="name" value="{$infos.name|default=''}" required="required" class="tpl-form-input" placeholder="请输入菜单名">
<!--                            <small>请填写标题文字10-20字左右。</small>-->
                        </div>
                    </div>
                    <div class="am-form-group">
                        <label class="am-u-sm-3 am-form-label">
                            前台菜单地址
                        </label>
                        <div class="am-u-sm-9">
                            <input type="text" name="router_url"  value="{$infos.router_url|default=''}" required="required"  class="tpl-form-input" placeholder="请输入菜单名">
                        </div>
                    </div>
                    <div class="am-form-group">
                        <label class="am-u-sm-3 am-form-label">
                            后台菜单地址
                        </label>
                        <div class="am-u-sm-9">
                            <input type="text" required="required"  value="{$infos.back_router|default=''}" name="back_router" class="tpl-form-input" placeholder="请输入菜单名">
                        </div>
                    </div>
                    <div class="am-form-group">
                        <label class="am-u-sm-3 am-form-label">
                            图标
                        </label>
                        <div class="am-u-sm-9">
                            <input type="text" required="required" name="icon" value="{$infos.icon|default='am-icon-home'}" class="tpl-form-input" placeholder="请输入菜单名">
                        </div>
                    </div>
                    <div class="am-form-group">
                        <label class="am-u-sm-3 am-form-label">
                            排序（升序）
                        </label>
                        <div class="am-u-sm-9">
                            <input type="text" required="required" name="list_order" value="{$infos.list_order|default='1000'}" class="tpl-form-input" placeholder="请输入菜单排序">
                        </div>
                    </div>
                    <div class="am-form-group">
                        <div class="am-u-sm-9 am-u-sm-push-3">
                            <button type="button" onclick="add('{:url($type)}','form')" class="am-btn am-btn-primary tpl-btn-bg-color-success" >
                                提交
                            </button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
    {/block}
{extend}